package com.awesome.spring.controller;

import com.awesome.spring.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * OrderController
 *
 * @author alex wu
 * @date 2022/07/09
 */
@RequestMapping("/order")
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * http://localhost:9002/order/create?userId=101&money=10&rollback=false
     * @param userId
     * @param money
     * @param rollback
     * @return
     */
    @RequestMapping("/create")
    public String create(String userId, int money, boolean rollback) {
        try {
            orderService.create(userId, money, rollback);
            return "下单成功";
        } catch (Exception e) {
            e.printStackTrace();
            return "下单失败";
        }
    }

}
